<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.10/dist/vue.min.js"></script>
    <style>
    </style>
  </head>
  <body>
    <div id="root">
     <input type="text" @keyup.capslock="showinfo">
     <h2 v-if="change">{{info}}</h2>
     </div>
  </body>
  <script>
    Vue.config.productionTip = false;
    Vue.config.keyCodes.capslock = 20
    new Vue({
      el: "#root",
      data() {
        return {
          info:"当前已切换大写模式",
          change:false
        }
      },
      methods: {
        showinfo(e){
          this.change=!this.change
        }
      },
    });
  </script>
</html>